home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / batchut / batutil1.zip / INPUTDEM.BAT < prev    next >
DOS Batch File  |  1990-03-25  |  3KB  |  108 lines

  1. :Batutil c(o) 1990 Barry Simon and Richard Wilson
  2. : Version 1.0
  3. echo off
  4. if exist batutil.exe goto buOK
  5. echo This demo file requires BATUTIL.EXE to be in the default drive and directory
  6. goto end
  7. :echo1
  8. Welcome to the @1FBATUTIL@1E user input demo
  9.   This demonstration will show how BATUTIL can get
  10.   information from the user.
  11.  
  12. :echo2
  13.  
  14. I would like to save your environment to env.tmp and
  15.      later restore it but that file exists
  16.    May I erase it (Y/N)?
  17.  
  18. :echo3
  19.  
  20. The first way to get information is the GETKEY command.  We'll try
  21.     @1FBATUTIL {GE y n}
  22. and you'll need to reply with one key or the other.  Your choice will get
  23. echoed on the screen; it can get returned in the errorlevel or the
  24. environmental variable RC.  Now
  25.  
  26.    Please hit Y or N :
  27. :echo4
  28.  
  29.    GETKEY is case insensitive and flushes the keyboard buffer before looking
  30. for a response but you can change that or change whether there is a visible
  31. echo.  You can specify that a wrong choice get beeped or that a choice not on
  32. the list just returns a special errorlevel.  You can have BATUTIL exit with
  33. errorlevel 0 if there is no response in a specified time.  You can even
  34. have the time shown in a ticking clock on screen.  We'll show you the
  35. effect of
  36.    @1FBATUTIL {EC You have $$L   seconds left}{GE WA12 EL}
  37. after you hit any key.
  38.  
  39.  
  40. :echo5
  41.  
  42.  
  43. BATUTIL will also pop up a menu for you to choose from with the choice
  44. returned in the errorlevel.  The file menudemo.bat illustrates this or, if
  45. you are running this as a choice from the main demo program, just choose
  46. the MENU DEMONSTRATION from the main menu.
  47.  
  48. You can test for whether the CAPSLOCK key is pressed and branch on that; this
  49. is ideal for making a choice at the start of a long batch file and then
  50. leaving the room.
  51.    @1FBATUTIL {QL C -}
  52. will return errorlevel 1 if on and 0 if off and turn it off if on.
  53.  
  54. Please hit CAPSLOCK and then another key to continue.
  55.  
  56.  
  57. :echo6
  58. The errorlevel return was $x(RC).
  59.  
  60. BATUTIL will also allow you to place strings in the environment.  First we'll
  61. ask you to input a string and then to choose a filename from BATUTIL's file
  62. picker.  Be sure to hit F1 when the file list is up to see what can be done.
  63. Now hit a key to continue.
  64.  
  65.  
  66. :echo7
  67.  
  68.  
  69. The string you entered was
  70. $S                     $x(foo)
  71. and the filename was
  72. $S                     $x(foo1)
  73. with a path of $x(FDIR)
  74.  
  75. Thanks for using BATUTIL.  Hit a key to exit.
  76.  
  77. :buOK
  78. set cur=off
  79. BATUTIL {CU -}{CLS}{RO 2}{CO 1}{FP %0 echo1}
  80. if x%1==xfrommain goto frommain
  81. if not exist env.tmp goto efileOK
  82. BATUTIL {CU -}{FE %0 echo2}{CU +}{GE Y N}
  83. if errorlevel 2 goto end
  84. erase env.tmp >nul
  85. :efileOK
  86. BATUTIL {set cur=}{SA env.tmp}{KI} >nul
  87. if errorlevel 200 goto envprob
  88. :frommain
  89. rem this is for calling main demo file
  90. set cur=off
  91. set a=
  92. set b=
  93. set c=
  94. BATUTIL {FP %0 echo3}{GE y n}{EC $_You picked choice $x(RC)$_}{FP %0 echo4}
  95. BATUTIL {AS}{EC You have $L   seconds left (or hit a key)}{GE WA12 EL}{CL}{FP %0 echo5}
  96. BATUTIL {AS}{QL C -}{FE %0 echo6}
  97. BATUTIL {AS}{CL}{EC $_$_Input a string$S}{set foo=$Q}{RO -1}{EOL +}{set foo1=$F}{FE %0 echo7}
  98. BATUTIL {GE WA5 EL}{set cur=}{EC $_}
  99. if x%1==xfrommain goto end
  100. BATUTIL {LO env.tmp} >nul
  101. erase env.tmp >nul
  102. goto end
  103. :envprob
  104. cls
  105. Echo  Problem setting up environment for this demo.  Sorry.
  106. :end
  107.  
  108.